<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('【请填写功能名称】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li>
                                名称：<input type="text" name="title"/>
                            </li>
                            <li>
                                审核状态：<select name="state" >
                                <option value="">所有</option>
                                <option value="0">未审核</option>
                                <option value="1">已审核</option>
                            </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="container-div">
                <div class="row">
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:doc:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:doc:remove')}]];
        var prefix = ctx + "system/topic";

        $(function() {
            var options = {
                url: prefix + "/listdoc?docs=[(${docs})]",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "文档管理",
                columns: [{
                    checkbox: true,
                    formatter: function(value, row, index) {
                        if (row.check)						//type 为是否选中状态值
                            return {
                                disabled : false,			//设置是否可用
                                checked : true				//设置选中
                            };
                        return value;

                    }
                },
                    {
                        field: 'docid',
                        title: '文档ID',
                        hidden:true
                    },


                {
                    field: 'title',
                    title: ' 标题'
                },
                {
                    field: 'typename',
                    title: '分类'
                },
                {
                    field: 'preview',
                    title: '免费'
                },
                {
                    field: 'readpay',
                    title: '阅读币'
                },
                {
                    field: 'downpay',
                    title: '下载币'
                },
                {
                    field: 'readcount',
                    title: '阅读量'
                },
                {
                    field: 'downcount',
                    title: '下载量'
                },
                {
                    field: 'pcount',
                    title: '页数'
                },
                {
                    field: 'docsize',
                    title: '大小'
                },
                {
                    field: 'insertdate',
                    title: '添加时间'
                },

                {
                    title: '标识',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.isvip==1)
                            actions.push('<span class="badge badge-primary">vip</span>');
                        if(row.isimp==1)
                            actions.push('<span class="badge badge-info">推荐</span>');
                        if(row.downpay==0)
                            actions.push('<span class="badge badge-success">免费</span>');
                        if(row.state==0)
                            actions.push('<span class="badge badge-warning">未审核</span>');
                        else
                            actions.push('<span class="badge badge-success">已审核</span>');
                        return actions.join('');
                    }
                },
           ]
            };
            $.table.init(options);
        });
        function resetPre() {
            resetDate();
            $("#formId")[0].reset();
            $.table.search();
        }
        function submitHandler(index, layero) {
            var rows = $.table.selectFirstColumns();
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            $.modal.close();
            // 父页面的方法
             activeWindow().selectUsers();
            // 父页面的变量
            //activeWindow().$('#userids').html('我是通过方式一来的：' + rows.join());
        }

        /* 添加用户-选择用户-提交(回调形式-父页面调用子页面) */
        function getSelections() {
            return $.table.selectFirstColumns1();
        }
    </script>
</body>
</html>